/**
 *网虫套餐
 */
public class NetPackage extends ServicePackage implements NetSevice {
    public int getTalkTime() {
        return talkTime;
    }

    public void setTalkTime(int talkTime) {
        this.talkTime = talkTime;
    }

    public int getSmsCount() {
        return smsCount;
    }

    public void setSmsCount(int smsCount) {
        this.smsCount = smsCount;
    }

    public int getFlwor() {
        return flwor;
    }

    public void setFlwor(int flwor) {
        this.flwor = flwor;
    }

    /*
     * 上网流量5GB
     * 资费68元
     */
   private int  talkTime=0;
   private int smsCount=0;
    private int flwor=5000;

    public NetPackage() {
        super();
        super.setPrice(68.0);
    }

    public NetPackage(int talkTime, int smsCount, int flwor) {
        super();
        this.talkTime = talkTime;
        this.smsCount = smsCount;
        this.flwor = flwor;
    }

    @Override
    public int netPlay(int flow, MoBileCard card) throws Exception {
        int temp=flow;
        for (int i = 1; i <flow ; i++) {
            if(this.flwor-card.getRealFlow()>=1){
                card.setRealFlow(card.getRealFlow()+1);
            }else if(card.getMoney()>=0.1){
                card.setRealFlow(card.getRealFlow()+1);
                card.setMoney(card.getMoney());
                card.setConsumAmount(card.getConsumAmount()+0.1);
            }else{
                temp=i;
                throw new Exception("本次已经上网"+i+"MB，您的余额不足，请充值后再使用");
            }
        }
        return temp;

        }


    @Override
    public void showInTo() {
        System.out.println("话痨套餐：通话时长为："+this.talkTime+"本月发送消息："+this.smsCount+"条，+上网流量为"+flwor+"GB");
    }


}
